package com.bilin.coin.activity;

import android.widget.LinearLayout;

import com.alibaba.android.arouter.facade.annotation.Autowired;
import com.alibaba.android.arouter.facade.annotation.Route;
import com.bilin.coin.R;
import com.bilin.coin.bean.CoinBean;
import com.bilin.coin.common.base.BaseAppCompatActivity;
import com.bilin.coin.list.CoinList;

import butterknife.BindView;

@Route(path = "/auction/AssertTradeListActivity")
public class AssertTradeListActivity extends BaseAppCompatActivity {

    @BindView(R.id.ll_main)
    LinearLayout ll_main;

    @Autowired
    int type;

    CoinList coinList;

    @Override
    protected void initView() {
        if (type == 0) {
            setTitle("充值列表");

        } else if (type == 1) {
            setTitle("提现列表");
        } else {
            setTitle("兑换列表");
        }

        coinList = new CoinList(this, type);
        coinList.refresh(true);
        ll_main.addView(coinList.getRootView());
        coinList.getAdapter().setOnItemClickListener((adapter, view, position) -> {
            CoinBean coinBean = (CoinBean) adapter.getData().get(position);
            if (type == 0) {
                if (coinBean.isCharge()) {
                    baseStartActivityWith("/order/RechargeCoinActivity").withParcelable("coinBean", coinBean).navigation();
                } else {
                    showToast("不可充币种");
                }
            } else if (type == 1) {
                if (coinBean.isWithdraw()) {
                    baseStartActivityWith("/order/WithdrawCoinActivity").withParcelable("coinBean", coinBean).navigation();
                } else {
                    showToast("不可提币种");
                }
            } else if (type == 2) {
                if (coinBean.getTitle().contains("USDT")) {
                    if (coinBean.getTitle().contains("矿币")) {
                        baseStartActivityWith("/auction/ExchangeUsdtActivity").withParcelable("coinBean", coinBean).navigation();
                    } else if (coinBean.getTitle().contains("USDT兑换WGP")){
                        baseStartActivityWith("/auction/ExchangeUsdtToWgpActivity").withParcelable("coinBean", coinBean).navigation();
                    } else {
                        baseStartActivityWith("/auction/ExchangeUsdtToMgpActivity").withParcelable("coinBean", coinBean).navigation();
                    }
                } else {
                    baseStartActivityWith("/auction/ExchangeActivity").withParcelable("coinBean", coinBean).navigation();
                }
            }
        });
    }

    @Override
    protected void initData() {

    }

    @Override
    protected int getLayoutId() {
        return R.layout.common_layout;
    }
}
